function POmsgInstallMassRecipients () {
    var tbl = POmsgGetTable ();
    if (!tbl) return;
    
    var tr = document.createElement ("tr");
    tr.innerHTML = "<th colspan=4><centre><a style='color:lime' href='javascript:POmsgShowMassRecipients();void(0);'>Show Mass PM Recipients list</a></centre></td>";
    tbl.firstChild.appendChild (tr);
}

function POmsgShowMassRecipients () {
    if (document.getElementById ("po_msg_recipients") != null) return;
    var tbl = POmsgGetTable ();
    if (!tbl) return;
    var names = POmsgGetNames ();
    if (!names) return;
    
    var tr = document.createElement ("tr");
    tr.innerHTML = "<td id='po_msg_recipients' colspan=4><span>"+names+"</span></td>";
    tbl.firstChild.appendChild (tr);
}

function POmsgGetNames () {
    var tbl = POmsgGetTable ();
    if (!tbl) return null;

    var names = "";
    var first = true;
    for (var row = 2; row<7; row ++) {
        var td = tbl.rows[row].cells[1];
        var spans = td.getElementsByTagName ("span");
        for (var i=0; i<spans.length; i++) {
            if (!first) names += ",";
            else first = false;
            names += spans[i].textContent;
        }
    }
    
    return names;
}

function POmsgGetTable () {
    var ths = document.getElementsByTagName ("span");
    
    for (var i=0; i<ths.length; i++) {
        if (ths[i].textContent == "(at the time of the most recent shift of faction-relations)") {
            return ths[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
        }
    }
    return null;
}

POmsgInstallMassRecipients ();